package com.teafriend.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @author 欧楚杨
 */
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfig {
    @Bean
    public Docket docketAdmin() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(b)
                .groupName("用户组")
                .select()
                .paths(PathSelectors.ant("/chuyangc/admin/**"))
//                .apis(RequestHandlerSelectors.basePackage("com.swaggerdemo.controller"))
                .build();
    }

    @Bean
    public Docket docketTeafriend() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(b)
                .groupName("茶友组")
                .select()
                .paths(PathSelectors.ant("/chuyangc/teafriend/**"))
//                .apis(RequestHandlerSelectors.basePackage("com.swaggerdemo.controller"))
                .build();
    }

    @Bean
    public Docket docketTea() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(b)
                .groupName("茶叶组")
                .select()
                .paths(PathSelectors.ant("/chuyangc/tea/**"))
//                .apis(RequestHandlerSelectors.basePackage("com.swaggerdemo.controller"))
                .build();
    }

    @Bean
    public Docket docketGoods() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(b)
                .groupName("订单组")
                .select()
                .paths(PathSelectors.ant("/chuyangc/goods/**"))
//                .apis(RequestHandlerSelectors.basePackage("com.swaggerdemo.controller"))
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("欧楚杨", "", "chu_yang1025@163.com");
        return new ApiInfo("茶友商城信息管理系统接口文档",
                "茶友商城信息管理系统",
                "1.0",
                "localhost",
                contact.getName(),
                "Apache 2.0",
                "");
    }
}

